<template>
  <div>
    <div class="topBar">
      <div class="logo">{{title}}</div>
      <div class="fullscreen">
        <full-screen></full-screen>
      </div>
      <el-dropdown trigger="click" class="person" @command="handleCommand">
        <img src="../assets/person.gif">
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="changePassword">修改密码</el-dropdown-item>
          <el-dropdown-item command="logout" divided>退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
import FullScreen from '@/components/FullScreen'
import { title } from '@/config'

export default {
  name: 'navbar',
  components: {
    FullScreen
  },
  data() {
    return {
      title: title
    }
  },
  created() {
  },
  methods: {
    handleCommand(command) {
      if (command === 'changePassword') {
        this.$message('您点击了修改密码')
      } else if (command === 'logout') {
        this.$emit('logout')
      }
    }
  }
}
</script>

<style scoped lang="stylus" rel="stylesheet/stylus">
.topBar
  position: fixed
  left: 0
  right: 0
  top: 0
  height: 50px
  line-height: 50px
  background: #222
  text-align: left
  .fullscreen
    position: absolute
    top:5px
    right: 80px
    width: 40px
    height: 40px
  .logo
    font-size 20px
    color #ffffff
    padding 0 50px
  .person
    width: 40px
    height: 40px
    margin: 5px
    position: absolute
    right: 20px
    top: 0
    cursor: pointer
    img
      width: 40px
      height: 40px
      border-radius: 4px
</style>